home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap04
/
AutomaticDoor.wrl
< prev
next >
Wrap
Text File
|
1996-10-14
|
4KB
|
139 lines
#VRML V2.0 utf8
#
# automatic door
# when the light is turned on, the door opens / closes automatically.
#
# turn off the headlight
NavigationInfo{
headlight FALSE
}
# initial viewpoint
Viewpoint{
position 0 2 5
}
# room
Shape{
geometry IndexedFaceSet{
solid FALSE # double face
coord Coordinate{
point[ 2 0 -10, #0
10 0 -10, #1
10 0 10, #2
-10 0 10, #3
-10 0 -10, #4
-2 0 -10, #5
2 3 -10, #6
10 3 -10, #7
10 3 10, #8
-10 3 10, #9
-10 3 -10, #10
-2 3 -10 #11
]
}
coordIndex[ 6, 0, 1, 7, -1, #0
7, 1, 2, 8, -1, #1
8, 2, 3, 9, -1, #2
9, 3, 4, 10, -1, #3
10, 4, 5, 11, -1, #4
4, 3, 2, 1 #5 (floor)
]
color Color{
color[ 1 1 0, #0 (wall)
0 0.2 1.0 #1 (floor)
]
}
colorPerVertex FALSE
colorIndex[ 0, 0, 0, 0, 0, 1]
}
}
DEF LIGHT1 DirectionalLight{
on FALSE
}
DEF LIGHT2 DirectionalLight{
direction 0 0 1
on FALSE
}
Transform{
translation 0 4 0
children[
# lamp shade
DEF LAMP_SHADE Shape{
geometry Cone{
height 2
bottomRadius 2
}
},
# sensor to turn the light on / off
DEF LIGHT_ON_SWITCH TouchSensor{}
]
}
Transform{
translation 0 1.5 -10.1
children[
# door
DEF DOOR Transform{
children[
Shape{geometry Box{size 4 3 0.1}}
]
},
DEF PROX_SENSOR ProximitySensor{
size 8 3 15
}
]
}
DEF DOOR_OPEN_TIME TimeSensor{
cycleInterval 2
}
DEF DOOR_OPEN_INTP PositionInterpolator{
key [ 0, 1]
keyValue [0 0 0, 3.5 0 0]
}
DEF DOOR_CLOSE_TIME TimeSensor{
cycleInterval 2
}
DEF DOOR_CLOSE_INTP PositionInterpolator{
key [ 0, 1]
keyValue [3.5 0 0, 0 0 0]
}
DEF DOOR_SCRIPT Script{
url "AutomaticDoor.class"
# light control
eventIn SFTime touched
eventOut SFBool turnOnLight
# door control
eventIn SFTime enterArea
eventOut SFTime openDoor
eventIn SFTime exitArea
eventOut SFTime closeDoor
}
ROUTE LIGHT_ON_SWITCH.touchTime TO DOOR_SCRIPT.touched
ROUTE DOOR_SCRIPT.turnOnLight TO LIGHT1.on
ROUTE DOOR_SCRIPT.turnOnLight TO LIGHT2.on
ROUTE PROX_SENSOR.enterTime TO DOOR_SCRIPT.enterArea
ROUTE DOOR_SCRIPT.openDoor TO DOOR_OPEN_TIME.set_startTime
ROUTE DOOR_OPEN_TIME.fraction_changed TO DOOR_OPEN_INTP.set_fraction
ROUTE DOOR_OPEN_INTP.value_changed TO DOOR.set_translation
ROUTE PROX_SENSOR.exitTime TO DOOR_SCRIPT.exitArea
ROUTE DOOR_SCRIPT.closeDoor TO DOOR_CLOSE_TIME.set_startTime
ROUTE DOOR_CLOSE_TIME.fraction_changed TO DOOR_CLOSE_INTP.set_fraction
ROUTE DOOR_CLOSE_INTP.value_changed TO DOOR.set_translation